﻿using System.Collections.Generic;
using System.Collections.Specialized;
using System.Web.Mvc;

namespace e_TicaretSistemi.Models
{
    public class HomeVm
    {
        public List<Product> ProductList { get; set; }
    }
    public class DefaultFilter
    {
        public string SearchString { get; set; }
        public Enums.ProductColumnEnum Sort { get; set; }
        public Enums.SortDirEnum SortDir { get; set; }
    }

    public static class UrlCreater
    {
        public static MvcHtmlString Create(Enums.ProductColumnEnum eColumnEnum, NameValueCollection collection)
        {
            var dir = "asc";
            var tag = new TagBuilder("a");
            var value = collection.Get("SortDir");
            if (!string.IsNullOrEmpty(value))
            {
                if (value == "asc")
                {
                    dir = "desc";
                }
            }

            tag.Attributes.Add("href", "/Product/Index" + "?Sort=" + eColumnEnum + "&SortDir=" + dir);

            switch (eColumnEnum)
            {
                case Enums.ProductColumnEnum.Price:
                    tag.SetInnerText("Fiyata Göre Sırala");
                    break;
                case Enums.ProductColumnEnum.Model:
                    tag.SetInnerText("Markaya Göre Sırala");
                    break;
                case Enums.ProductColumnEnum.Title:
                    tag.SetInnerText("Başlığa Göre Sırala");
                    break;
            }
            return new MvcHtmlString(tag.ToString());
        }
    }
}
